#!/bin/bash
set -e

export DISPLAY=:0
cd /home/linaro/Desktop/cabinet_board

if ping -c 1 gitee.com >/dev/null 2>&1; then
  echo "==== git pull with credentials ===="
  git pull https://bdy-fan-wenyu:Fwy20030721@gitee.com/bdy-fan-wenyu/cabinet_board.git || exit 1
else
  echo "==== 离线模式，跳过 git pull ===="
fi

echo "==== build ===="
cd build
cmake ..
make -j2

# 编译完成后直接在当前终端运行主程序
./cabinet_board_main

echo "==== done ===="